RewriteEngine on

RewriteRule ^/v2/latest/(.*) /v2/f27/$1 [R,L]

{% if env == "staging-new" %}
RewriteRule ^/v2/(.*) /v2/fedora/$1
{% endif %}

RewriteRule ^/signatures/(.*) /srv/web/registry-signatures/$1 [L]

<Directory /srv/web/registry-signatures>
    Require all granted
</Directory>

{% include './reversepassproxy.registry-generic.conf' %}

# Write access to docker-deployer only
{% if env == "staging-new" %}
  <Location /v2/fedora>
    <LimitExcept GET HEAD>
      Require user docker-registry-internal-stg
    </LimitExcept>
  </Location>
  <Location /v2/centos>
    Require all denied
  </Location>

{% else %}

<Location /v2>
  <Limit GET HEAD>
    require all granted
  </Limit>
  <LimitExcept GET HEAD>
    require valid-user
  </LimitExcept>
</Location>
{% endif %}
